package enums;

import java.util.HashMap;
import java.util.Map;

/**
 * Provides the names of the keys stored in the properties table of the database.
 */
public enum Property {
	
	COUNTER("counter"),
	PROFITSHARING("profitsharing"),
	OPTIONALPROFITSHARING("optprofitsharing"),
	SALARY("salary"),
	OPERATORSALARY("operatorsalary"),
	PATHUSBSTICK("pathusb"),
	PASSWORDEMAIL("passwordemail"),
	USERNAMEEMAIL("usernameemail"),
	SALTEMAIL("saltemail"), 
	BILLCOUNTER("billcounter"),
	PURCHASECOUNTER("purchasecounter");
	
	/**
	 * name as String for a Customer
	 */
	private final String name;
	
	/**
	 * Map of all existing Customers
	 */
	private static final Map<String, Property> stringToProperty = new HashMap<>();

	static {
		for (Property f : Property.values()) {
			stringToProperty.put(f.toString(), f);
		}
	}

	/**
	 * Standard constructor of a Customer
	 * 
	 * @param name which will be added to a single Reason
	 */
	private Property(String name) {
		this.name = name;
	}

	/**
	 * Returns a String for a Customer
	 */
	@Override
	public String toString() {
		return name;
	}
	/**
	 * Returns a Customer for a String
	 *
	 * @param s String which will be transformed into a Reason
	 * @return the Reason
	 */
	public static Property fromString(String s){
		return Property.stringToProperty.get(s);
	}
}
